package top.du1888.ai.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.du1888.ai.AiApplication;
import top.du1888.ai.interceptor.LoginInterceptor;

@SpringBootApplication
// mybatis 中 mapper 接口扫描器，指定参数为：mapper 接口所在路径
// 功能：将包中路径下所有接口动态代理，创建 mapper 接口实现类交给 spring 容器管理
@MapperScan(basePackages = "top.du1888.ai.mapper")
public class MvcJavaConfig<PermissionInterceptor> implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

//    @Autowired
//    private PermissionInterceptor permissionInterceptor;

    public void addInterceptors(InterceptorRegistry registry) {
        // 注册登录拦截器
        registry.addInterceptor(loginInterceptor)
                // 对哪些资源起过滤作用
                .addPathPatterns("/**")
                // 对哪些资源起排除作用
                .excludePathPatterns("/loginUser","/login.html","/css/**","/js/**");

    }

    public static void main(String[] args) {
        SpringApplication.run(AiApplication.class, args);
    }
}
